package com.ymatou.query.seller.trading.api.parameter;

import com.ymatou.query.trading.api.parameter.OrderConverter;
import com.ymttest.common.entitie.OrderItemInfo;
import com.ymttest.common.entitie.OrderItemInfoExt;
import com.ymttest.common.enums.SalesTypeStringEnum;
import com.ymttest.utils.DataUtil;

public class Ymt_OrderInfoExtension {
	public static OrderItemInfo ConvertToOrderItemInfo(
			com.ymatou.query.seller.trading.api.parameter.Ymt_OrderInfo o) {
		OrderItemInfo i = new OrderItemInfo();
		if (o == null) {
			return null;
		}
		OrderItemInfoExt orderItemInfoExt = null;
		if (o.getsOrderInfoExtId() != null) {
			orderItemInfoExt = new OrderItemInfoExt();
			orderItemInfoExt.setActivityId(DataUtil.Integerr
					.GetValueOrDefault(o.getiActivityId()));
			orderItemInfoExt.setActivityTemplateId(DataUtil.Integerr
					.GetValueOrDefault(o.getiActivityTemplateId()));
			orderItemInfoExt.setGiftAvail4Reward(DataUtil.Booleann
					.GetValueOrDefault(o.getbGiftAvail4Reward()));
		}
		i.setSailProtected(o.getiSailProtected());
		i.setPrice(o.getfOriginalPrice());
		i.setPropertyInfo(o.getsPropertyInfo());
		i.setAmount(DataUtil.Integerr.GetValueOrDefault(o.getiAmount()));
		i.setItemType(o.getiType());
		i.setCatalogId(o.getsCatalogId());
		i.setSku(o.getsSKU());
		i.setProductId(o.getsProductId());
		i.setDescription(o.getsDescription());
		i.setOrderItemId(o.getsOrderInfoId());
		i.setPictureUrl(o.getsPictureUrl());
		//		i.setReferenceUrl(o.getsPictureUrl());
		i.setReferenceUrl(o.getsReferenceUrl());
		i.setTitle(o.getsTitle());
		i.setSubProductCategoryId(o.getiProductSubCategoryId());
		i.setLogisticsType(o.getiCatalogStatus());
		i.setStockStatus(o.getiCatalogType());
		i.setBondedArea(DataUtil.Integerr.GetValueOrDefault(o.getiBondedArea()));
		i.setPriceType(o.getiPriceType());
		i.setOrderItemInfoExt(orderItemInfoExt);
		i.setProductRefundChannel(o.getiProductRefundChannel());
		i.setFreight(o.getfFreight());
		i.setFreightFree(o.getbFreightFree());
		i.setSellerCouponAmount(DataUtil.BigDecimall.GetValueOrDefault(o
				.getfSellerCouponAmount()));
		i.setYmtCouponAmount(DataUtil.BigDecimall.GetValueOrDefault(o
				.getfYmtCouponAmount()));
		i.setProductOriginalPrice(DataUtil.BigDecimall.GetValueOrDefault(o
				.getfProductOriginalPrice()));
		i.setProductPrice(DataUtil.BigDecimall.GetValueOrDefault(o
				.getfProductPrice()));
		i.setDiscount(o.getfDiscount());
		i.setRefundBillNo(o.getRefundBillNo());
		i.setTariffType(o.getiTariffType());
		i.setSalesType(SalesTypeStringEnum.forValue(DataUtil.Integerr
				.GetValueOrDefault(o.getiSalesType())));
		i.setPromotion(OrderConverter.GetPromotion(o));
		i.setSupportRtnWithoutReason(o.isbSupportRtnWithoutReason());
		i.setPreSale(DataUtil.Booleann.GetValueOrDefault(o.getbPreSale()));
		i.setThirdPartyDiscount(DataUtil.BigDecimall.GetValueOrDefault(o
				.getfThirdPartyDiscount()));
		i.setPspProduct(o.isbPspProduct());
		return i;
	}
}
